﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Staticage.Util;
using Staticage.Core;

namespace Staticage.Data
{
    /// <summary>
    /// 分页数据
    /// </summary>
    [Serializable]
    public class PageData
    {
        public long TotalCount { set; get; }
        public IEnumerable Datas { set; get; }


        public PageData(IEnumerable datas, long totalCount)
        {
            Preconditions.CheckNotNull(datas, "datas");
            this.Datas = datas;
            this.TotalCount = totalCount;
        }

        public PageData()
        { }
    }

    /// <summary>
    /// 分页数据(泛型)
    /// </summary>
    [Serializable]
    public class PageData<T>
    {
        /// <summary>
        /// 数据总记录数
        /// </summary>
        public long TotalCount { set; get; }

        /// <summary>
        /// 数据集合
        /// </summary>
        public IEnumerable<T> Datas { set; get; }

        /// <summary>
        /// 初始化分页数据对象
        /// </summary>
        /// <param name="datas">数据集合</param>
        /// <param name="totalCount">总记录数</param>
        public PageData(IEnumerable<T> datas, long totalCount)
        {
            Preconditions.CheckNotNull(datas, "datas");
            this.Datas = datas;
            this.TotalCount = totalCount;
        }

        public PageData()
        { }
    }
}
